<%@ page contentType="text/html; charset=UTF-8" import="java.util.Hashtable,com.pub.database.*"%>
<%
String strDBAlias = "PIS1_WFLOW";
String strUserName = strDBAlias.substring(strDBAlias.indexOf("_")+1);
Hashtable lhtTableList = null;
Hashtable lhtTableIndex = null;
QueryBean qbnDAO = null;
StringBuffer stbNoIndexTableList = new StringBuffer();
boolean blnHaveTable = false;

try{
  qbnDAO = new QueryBean(strDBAlias,false,"big5","big5");

  lhtTableList = DBFunction.getDBObjects(qbnDAO.getConnection().getMetaData(),true,strUserName,new String[]{"TABLE"});

  blnHaveTable = !(lhtTableList==null || lhtTableList.isEmpty() || lhtTableList.size()==0);

    for(int i=0;i<lhtTableList.size();i++){
      lhtTableIndex = DBFunction.getIndexInfo(qbnDAO.getConnection().getMetaData(),false,strUserName,((Hashtable)lhtTableList.get(String.valueOf(i))).get("TABLE_NAME").toString());

      System.out.print(i);
      System.out.print(" now check ");
      System.out.print(((Hashtable)lhtTableList.get(String.valueOf(i))).get("TABLE_NAME").toString());
      System.out.print("==>");
      System.out.println(lhtTableIndex==null || lhtTableIndex.isEmpty() ? 0 : lhtTableIndex.size());

      if(lhtTableIndex==null || lhtTableIndex.isEmpty() || lhtTableIndex.size()==0){
        stbNoIndexTableList.append(((Hashtable)lhtTableList.get(String.valueOf(i))).get("TABLE_NAME").toString());
        stbNoIndexTableList.append("<br/>");
      }
    }
}
catch(Exception e){
  e.printStackTrace();
}
finally{
  if(qbnDAO!=null){
    try{qbnDAO.close();qbnDAO=null;}catch(Exception e){e.printStackTrace();}
  }
}


%>
<html>
<head>
<title>
checkNoIndexTable
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<%=strDBAlias %>
</h1>
<br><br>
<p><%=(blnHaveTable ? "此User沒有權限執行此命令或此User下沒有Table" : stbNoIndexTableList.toString())%></p>
</body>
</html>
